package com.lly.schedule.dao.impl;

import com.lly.schedule.dao.BaseDao;
import com.lly.schedule.dao.SysUserDao;
import com.lly.schedule.pojo.SysUser;

import java.util.List;

public class SysUserDaoImpl extends BaseDao implements SysUserDao {

    @Override
    public int addUser(SysUser sysUser) throws Exception {
        String sql = "insert into sys_user values(DEFAULT,?,?)";
        return baseUpdate(sql,sysUser.getUsername(),sysUser.getUserPwd());
    }

    @Override
    public SysUser login(String username) throws Exception {
        String sql="select uid,username,user_pwd as userPwd from sys_user where username =?";
        List<SysUser> sysUsers = baseQuery(SysUser.class, sql,username);
        return sysUsers!=null && sysUsers.size()>0?sysUsers.get(0):null;
    }
}
